namespace MoreLinq.Test;

using System;
using System.Diagnostics;
using System.Globalization;

static class Extensions
{
    /// <summary>
    /// Formats the value of this object using the invariant culture.
    /// </summary>

    [DebuggerStepThrough]
    public static string ToInvariantString<T>(this T formattable) where T : IFormattable =>
        formattable.ToInvariantString(null);

    /// <summary>
    /// Formats the value of this object using a specific format and the
    /// invariant culture.
    /// </summary>

    [DebuggerStepThrough]
    public static string ToInvariantString<T>(this T formattable, string? format) where T : IFormattable
    {
            if (formattable is null) throw new ArgumentNullException(nameof(formattable));
            return formattable.ToString(format, CultureInfo.InvariantCulture);
        }
}
